package leetcode.offer;

/**
 * @ClassName T06
 * @Description TODO
 * @Author Fanxc
 * @DATE 2020/11/29 0029 21:29
 * @Version 1.0
 */
public class T06 {
    class ListNode {
        int val;
        ListNode next;
        ListNode(int x) { val = x; }
    }
    class Solution {
        public int[] reversePrint(ListNode head) {
            ListNode cur = head;
            int i = 0;
            while (cur != null) {
                cur = cur.next;
                i++;
            }
            int[] sz = new int[i];
            cur = head;
            for (int j = i - 1; j >= 0; j--) {
                sz[j] = cur.val;
                cur = cur.next;
            }
            return sz;
        }
    }
}
